<?php
class CommentAction extends MbaseAction {
	public $tbname = 'Comment';
	public $obj = '';
	public $mpk = 'comment_id';
	public function reply(){
		$mpk = isset($_POST['comment_id'])? $_POST['comment_id']:'';
		$note = isset($_POST['reply'])? $_POST['reply']:'';
		if($mpk == '' || $note == '') $this->error('参数错误',1,'');
		$mnote = M('Comment');
		if(!$mnote->where('comment_id='.$mpk)->setField('reply',$note)){
			 $this->error($mnote->getError(),1,'');
			 return false;
		}
		$this->setForward(U('view?comment_id='.$mpk));
		$this->success('回复成功',1,'');
	}
	public function seeable(){
		$mpk = isset($_POST['comment_id'])? $_POST['comment_id']:0;
		$seelock = isset($_POST['seelock'])? $_POST['seelock']:1;
		if($mpk == 0) $this->error('参数错误',1,'');
		$map['comment_id'] = $mpk;
		$mof = D('Comment');
		$cinfo = $mof->where($map)->find();
		if($mof->where($map)->setField('progress',$seelock)){
			//$this->setForward(U('view?comment_id='.$mpk));
			$this->setForward(U('index'));
			if($seelock == 1){
				$this->success('评论已屏蔽。',1,'');
			}else{
				$this->success('评论已显示。',1,'');
			}
			
		}else{
			$this->error('参数错误',1,'');
		}
	}
}
?>